<?php

/**
 * Address form base class.
 *
 * @method Address getObject() Returns the current form's model object
 *
 * @package    makethetouch
 * @subpackage form
 * @author     Sebastien Chassande-Barrioz
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAddressForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'address'          => new sfWidgetFormInputText(),
      'country'          => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Country'), 'add_empty' => false)),
      'city'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('City'), 'add_empty' => false)),
      'idaddress'        => new sfWidgetFormInputHidden(),
      'zipcode'          => new sfWidgetFormInputText(),
      'gps'              => new sfWidgetFormInputText(),
      'google_maps_link' => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'address'          => new sfValidatorString(array('max_length' => 50)),
      'country'          => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Country'))),
      'city'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('City'))),
      'idaddress'        => new sfValidatorChoice(array('choices' => array($this->getObject()->get('idaddress')), 'empty_value' => $this->getObject()->get('idaddress'), 'required' => false)),
      'zipcode'          => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'gps'              => new sfValidatorString(array('max_length' => 25, 'required' => false)),
      'google_maps_link' => new sfValidatorString(array('max_length' => 200, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('address[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Address';
  }

}
